home *** CD-ROM | disk | FTP | other *** search
- dnl Process this file with autoconf to produce a configure script.
-
- AC_INIT(pl-wam.c)
-
- AC_CONFIG_HEADER(config.h)
- AC_SUBST(PLBASE)
- AC_SUBST(STATICLIBS)
- AC_SUBST(COFLAGS)
- AC_SUBST(CWFLAGS)
- AC_SUBST(CMFLAGS)
- AC_SUBST(CIFLAGS)
- AC_SUBST(AR)
- AC_SUBST(ETAGS)
- AC_SUBST(LDFLAGS)
- AC_SUBST(STATICLIBS)
- AC_SUBST(ARCH)
- AC_SUBST(PLFOREIGN)
- AC_SUBST(PL)
- AC_SUBST(RT)
- AC_SUBST(PLVERSION)
- AC_SUBST(VPATH)
- AC_SUBST(COUTOPT)
- AC_SUBST(INSTALLTARGET)
-
- INSTALLTARGET=dv-install
- PL=pl
- RT=""
- PLVERSION=`cat ../VERSION`
-
- dnl ****************************************************************
- dnl Some systems don't appear to have true. Hope all like this ...
- dnl ****************************************************************
-
- true()
- { test a = a
- }
-
- AC_PROG_CC
- AC_PROG_RANLIB
- AC_CANONICAL_HOST
- changequote(,)dnl
- ARCH=`echo $host | sed 's/\([^-]*\)-[^-]*-\([^-]*\)/\1-\2/'`
- changequote([,])dnl
-
- AC_ARG_ENABLE(syslibh, [ --enable-syslibh Prototype file to enable gcc -Wall],
- [case "$enableval" in
- yes) AC_DEFINE(SYSLIB_H, "syslib.h")
- syslibh=yes ;;
- no) ;;
- *) AC_DEFINE(SYSLIB_H, "$enableval")
- syslibh=yes ;;
- esac])
-
- AC_ARG_ENABLE(runtime, [ --enable-runtime Runtime system only],
- [case "$enableval" in
- yes) AC_DEFINE(O_RUNTIME)
- runtime=yes
- RT=rt
- INSTALLTARGET=rt-install ;;
- *) ;;
- esac])
-
-
- dnl ****************************************************************
- dnl Checking for GNU make vpath construct
- dnl ****************************************************************
-
- AC_CHECK_PROGS(MAKE, make gmake, "make")
- AC_MSG_CHECKING("whether make is GNU-make")
- if ($MAKE -v 2>&1) | grep GNU > /dev/null; then
- AC_MSG_RESULT(yes)
- VPATH="vpath %.c"
- else
- VPATH="VPATH = "
- AC_MSG_RESULT(no)
- fi
-
- dnl ****************************************************************
- dnl Finding various programs
- dnl ****************************************************************
-
- AC_CHECK_PROG(AR, ar, ar, ar)
- AC_CHECK_PROGS(ETAGS, etags ctags, ":")
- AC_PROG_AWK
- AC_PROG_INSTALL
- case "$INSTALL" in
- ./*) if test -z "$PWD"; then PWD=`pwd`; fi
- INSTALL="$PWD/$INSTALL" ;;
- esac
- AC_PROG_CPP
- AC_ISC_POSIX
- AC_HEADER_STDC
- if test "$GCC" = "yes"; then
- COFLAGS=-O2
- if test "$ac_cv_header_stdc" = "yes" || test "$syslibh" = "yes"; then
- CWFLAGS=-Wall
- else
- CWFLAGS=
- fi
- CMFLAGS=-funsigned-char
- else
- COFLAGS=-O
- CWFLAGS=
- CMFLAGS=
- fi
- CFLAGS="$CMFLAGS"
- AC_C_INLINE
- AC_FUNC_ALLOCA
- AC_C_BIGENDIAN
-
- dnl ****************************************************************
- dnl Finding libraries
- dnl ****************************************************************
-
- AC_CHECK_LIB(m, main)
- AC_CHECK_LIB(termcap, main)
- if test "$ac_cv_lib_termcap_main" = "yes"; then
- AC_MSG_CHECKING("whether -ltermcap needs -lucb")
- AC_TRY_LINK([],
- [ tgetent();
- ],
- AC_MSG_RESULT(no)
- true,
- AC_MSG_RESULT(maybe ...)
- checkucb=yes)
- else
- AC_CHECK_LIB(ncurses, main)
- if test ! "$ac_cv_lib_ncurses_main" = "yes"; then
- AC_CHECK_LIB(curses, main)
- fi
- fi
- if test "$checkucb" = "yes"; then
- AC_CHECK_LIB(ucb, rindex)
- fi
- if test ! "$runtime" = "yes"; then
- AC_CHECK_LIB(readline, main)
- if test ! "$ac_cv_lib_readline_main" = "yes"; then
- AC_CHECK_LIB(ncurses, main)
- if test ! "$ac_cv_lib_ncurses_main" = "yes"; then
- AC_CHECK_LIB(curses, main)
- fi
- if test "$ac_cv_lib_ncurses_main" = "yes" || test "$ac_cv_lib_curses_main" = "yes"; then
- echo "Found curses library. See if -lreadline works now"
- unset ac_cv_lib_readline_main
- AC_CHECK_LIB(readline, main)
- fi
- fi
- fi
- AC_ARG_ENABLE(shared, [ --disable-shared No shared-lib interface],
- configshared="$enableval",
- configshared=yes)
- AC_ARG_ENABLE(save, [ --enable-save Provide save/1 and friends],
- configsave="$enableval",
- configsave=no)
-
- if test "$configsave" = "yes"; then
- AC_CHECK_LIB(elf, main)
- fi
- if test "$configshared" = "yes"; then
- AC_CHECK_LIB(dl, dlopen)
- AC_CHECK_LIB(dld, shl_load)
- AC_CHECK_FUNCS(dlopen)
- AC_CHECK_FUNCS(shl_load)
- fi
-
- if test "$ac_cv_func_dlopen" = "yes" || \
- test "$ac_cv_func_shl_load" = "yes"; then
- configloadforeign=no
-
- AC_MSG_CHECKING(for cc -c -o)
- cat > conftest.c << _EOP_
- main()
- { exit(0);
- }
- _EOP_
- if ${CC-cc} $CFLAGS -c conftest.c -o conftest.o 1>&5 2>&5 && test -r conftest.o; then
- COUTOPT='-o $@'
- AC_MSG_RESULT(yes)
- else
- COUTOPT=
- AC_MSG_RESULT(no)
- fi
- rm -rf conftest.*
-
- dnl Some versions of (g)cc need to export the symbols from the main program
- dnl using -export-dynamic or (older versions) -rdynamic. See whether
- dnl this gcc understands this flag.
-
- AC_MSG_CHECKING("whether LDFLAGS need -export-dynamic")
- old_ldflags="$LDFLAGS"
- LDFLAGS="-export-dynamic $LDFLAGS"
- AC_TRY_RUN(
- main()
- { exit(0);
- },
- if grep 'unrecognized option `-export-dynamic'"'" config.log >/dev/null; then
- AC_MSG_RESULT(no)
- LDFLAGS="$old_ldflags"
- else
- AC_MSG_RESULT(yes)
- exportdynamic=done
- fi,
- AC_MSG_RESULT(no)
- LDFLAGS="$old_ldflags",
- AC_MSG_RESULT(no)
- LDFLAGS="$old_ldflags")
-
- if test "$exportdynamic" != "done"; then
- AC_MSG_CHECKING("whether LDFLAGS need -rdynamic")
- old_ldflags="$LDFLAGS"
- LDFLAGS="-rdynamic $LDFLAGS"
- AC_TRY_RUN(
- main()
- { exit(0);
- },
- if grep 'unrecognized option `-rdynamic'"'" config.log >/dev/null; then
- AC_MSG_RESULT(no)
- LDFLAGS="$old_ldflags"
- else
- AC_MSG_RESULT(yes)
- fi,
- AC_MSG_RESULT(no)
- LDFLAGS="$old_ldflags",
- AC_MSG_RESULT(no)
- LDFLAGS="$old_ldflags")
- fi
- else
- configloadforeign=yes
- fi
-
- echo " LIBS=$LIBS"
-
- AC_CHECK_HEADERS(unistd.h string.h memory.h sys/time.h sys/stat.h pwd.h)
- AC_CHECK_HEADERS(sys/select.h sys/param.h sys/file.h sys/resource.h malloc.h)
- AC_CHECK_HEADERS(sys/termios.h sys/termio.h bstring.h)
- AC_CHECK_HEADERS(mach-o/rld.h)
-
- AC_CHECK_FUNCS(access chmod dossleep fstat readlink getwd getcwd getdtablesize)
- AC_CHECK_FUNCS(getpagesize getpwnam getrlimit gettimeofday opendir sysconf)
- AC_CHECK_FUNCS(popen putenv random remove rename rl_insert_close select)
- AC_CHECK_FUNCS(signal sigset sleep srand srandom stat strerror tgetent times)
- AC_CHECK_FUNCS(memmove stricmp strlwr sigaction sigsetmask siggetmask sigblock)
- AC_CHECK_FUNCS(rint aint floor ceil isnan tcsetattr cfmakeraw)
- AC_HEADER_TIME
- AC_HEADER_DIRENT
- AC_HEADER_SYS_WAIT
- AC_FUNC_VFORK
-
- AC_MSG_CHECKING("alignment restrictions on doubles")
- AC_TRY_RUN(
- [ main()
- { long l[10];
- double *p;
- unsigned long x = (unsigned long) l;
-
- if ( x % sizeof(double) == 0 )
- x += sizeof(long);
- p = (double *) x;
- *p = 1.0;
-
- exit(0);
- }
- ],
- AC_MSG_RESULT(as long),
- AC_MSG_RESULT(sizeof(double))
- AC_DEFINE(DOUBLE_ALIGNMENT, sizeof(double)),
- AC_MSG_RESULT(assuming sizeof(double))
- AC_DEFINE(DOUBLE_ALIGNMENT, sizeof(double)))
-
- if test "$ac_cv_func_getrlimit" = "yes"; then
- AC_MSG_CHECKING("type rlim_t")
- AC_TRY_COMPILE(
- [
- #include <sys/types.h>
- #include <sys/resource.h>
- ],
- [ rlim_t datasize;
- ], AC_DEFINE(HAVE_RLIM_T)
- AC_MSG_RESULT(yes),
- AC_MSG_RESULT(no))
- fi
-
- AC_MSG_CHECKING("whether assert.h needs stdio.h")
- AC_TRY_COMPILE(
- [
- #include <assert.h>
- ],
- [ assert(1);
- ], AC_MSG_RESULT(no),
- AC_MSG_RESULT(yes);
- AC_DEFINE(ASSERT_H_REQUIRES_STDIO_H))
-
- AC_CHECKING("for including sys/ioctl.h after sys/termios.h")
- if test "$GCC" = "yes"; then
- ac_oldcflags="$CFLAGS"
- CFLAGS="$CFLAGS -Werror"
- fi
- AC_TRY_COMPILE(
- [
- #include <stdio.h>
- #include <sys/types.h>
- #include <sys/termios.h>
- #include <sys/ioctl.h>
- ],
- [;
- ], true, AC_DEFINE(NO_SYS_IOCTL_H_WITH_SYS_TERMIOS_H))
- if test "$GCC" = "yes"; then CFLAGS="$ac_oldcflags"; fi
-
- if test -z "$ac_cv_header_sys_termio_h" -a -z "$ac_cv_header_sys_termios_h"; then
- AC_MSG_CHECKING("struct sgttyb")
- AC_TRY_COMPILE(
- [
- #include <sys/types.h>
- #include <sys/ioctl.h>
- ],
- [ struct sgttyb buf;
- ;
- ], AC_DEFINE(HAVE_SGTTYB)
- AC_MSG_RESULT(yes),
- AC_MSG_RESULT(no))
- fi
-
-
- AC_MSG_CHECKING("for type uchar")
- AC_TRY_COMPILE(
- [
- #include <sys/types.h>
- typedef unsigned char uchar;
- ],
- [;], AC_DEFINE(NEED_UCHAR)
- AC_MSG_RESULT("need typedef uchar"),
- AC_MSG_RESULT("uchar predefined"))
-
- AC_MSG_CHECKING("whether we need extern int errno")
- AC_TRY_COMPILE(
- [
- #include <sys/types.h>
- #include <stdio.h>
- #include <errno.h>
- ],
- [ return errno;
- ], AC_MSG_RESULT(no),
- AC_DEFINE(NEED_DECL_ERRNO)
- AC_MSG_RESULT(yes))
-
- AC_MSG_CHECKING("for symbolic links")
- if touch conftest.x && ln -s conftest.x conftest.lns && cmp conftest.x conftest.lns; then
- AC_DEFINE(HAVE_SYMLINKS)
- AC_MSG_RESULT(yes)
- else
- AC_MSG_RESULT(no)
- fi
-
- AC_TYPE_SIGNAL
- AC_MSG_CHECKING("for BSD signal handlers")
- AC_TRY_RUN(
- [
- #include <stdio.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <signal.h>
- #ifdef HAVE_UNISTD_H
- #include <unistd.h>
- #endif
- static int signalled;
- static RETSIGTYPE catch (s) int s; { signalled = 1; }
- main()
- { signal(SIGINT, catch);
- kill(getpid(), SIGINT);
- while(!signalled)
- ;
- if ( signal(SIGINT, catch) == catch )
- exit(0);
- exit(1);
- }], AC_DEFINE(BSD_SIGNALS)
- AC_MSG_RESULT("BSD signals"),
- AC_MSG_RESULT("Posix signals"),
- AC_MSG_RESULT("assuming Posix signals"))
-
- AC_MSG_CHECKING("for SIGPROF profiler support")
- AC_TRY_RUN([
- #ifdef TIME_WITH_SYS_TIME
- #include <sys/time.h>
- #include <time.h>
- #else
- #ifdef HAVE_SYS_TIME_H
- #include <sys/time.h>
- #else
- #include <time.h>
- #endif
- #endif
- #include <signal.h>
- static RETSIGTYPE prof(s) int s; {exit(0);}
- main()
- { struct itimerval value, ovalue;
- int n;
- value.it_interval.tv_sec = 0;
- value.it_interval.tv_usec = 1;
- value.it_value.tv_sec = 0;
- value.it_value.tv_usec = 1;
-
- signal(SIGPROF, prof);
-
- if (setitimer(ITIMER_PROF, &value, &ovalue) != 0)
- exit(1);
-
- for(n=0; n<10000000; n++)
- ;
- exit(1);
- }], AC_DEFINE(O_PROFILE)
- AC_MSG_RESULT(yes),
- AC_MSG_RESULT(no),
- true)
-
- AC_MSG_CHECKING("for union wait")
- if test "$GCC" = yes; then
- ac_oldcflags="$CFLAGS"
- CFLAGS="$CFLAGS -Werror"
- fi
- AC_TRY_COMPILE(
- [
- #include <sys/wait.h>
- ],
- [ union wait status;
- waitpid(1, &status, WNOHANG);
- ], AC_DEFINE(UNION_WAIT)
- AC_MSG_RESULT(yes),
- AC_MSG_RESULT(no))
- if test "$GCC" = "yes"; then CFLAGS="$ac_oldcflags"; fi
-
- AC_MSG_CHECKING("for tagged lvalues")
- AC_TRY_COMPILE(
- [
- ],
- [ int x;
- *(char *)&x = 'a';
- exit(0);
- ], AC_DEFINE(TAGGED_LVALUE)
- AC_MSG_RESULT(yes),
- AC_MSG_RESULT(no))
-
-
- dnl ****************************************************************
- dnl Very specific SWI-Prolog tests. First of all, we'll try to determine
- dnl the direction of the C-stack as well as the area where malloc()'ed data
- dnl lifes. We run test/memmodel.c for this.
- dnl ****************************************************************
-
- AC_MSG_CHECKING("memory model");
- echo '#include "confdefs.h"' > conftest.c
- cat $srcdir/test/memmodel.c >> conftest.c
- (eval $ac_link) 2>&5
- if test -s conftest && eval `./conftest`; then
- AC_DEFINE_UNQUOTED(STACK_DIRECTION, $STACK_DIRECTION)
- AC_MSG_RESULT(yes)
- else
- AC_MSG_WARN("Failed to compile test/memmodel.c")
- fi
- rm -fr conftest*
-
- dnl ****************************************************************
- dnl Test whether we can use asm("nop") to separate instructions.
- dnl Needed for gcc version 2 (see pl-wam.c)
- dnl ****************************************************************
-
- AC_MSG_CHECKING("for nop");
- echo '#include "confdefs.h"' > conftest.c
- cat $srcdir/test/nop.c >> conftest.c
- (eval $ac_link) 2>&5
- if test -s conftest && eval `./conftest`; then
- AC_MSG_RESULT(yes)
- else
- AC_DEFINE(NO_ASM_NOP)
- AC_MSG_RESULT(no)
- fi
- rm -fr conftest*
-
-
- dnl ****************************************************************
- dnl More tricky stuff. Try to find out whether or not we can use mmap()
- dnl to implement dynamic stacks. This requires mmap(), support for
- dnl `fixed' and `private' maps and support to map in the same area as
- dnl malloc() does. The program map/mmap.c tests all these things.
- dnl ****************************************************************
-
- AC_MSG_CHECKING("if we can use mmap for stack allocation")
- echo '#include "confdefs.h"' > conftest.c
- cat $srcdir/test/mmap.c >> conftest.c
- (eval $ac_link) 2>&5
- if test -s conftest && eval `./conftest`; then
- if test "$MMAP_STACK" = "1"; then
- if test "$HAVE_MAP_ANON" = "1"; then
- AC_DEFINE(HAVE_MAP_ANON)
- AC_MSG_RESULT("Using MAP_ANON")
- else
- AC_MSG_RESULT("Using MAP_PRIVATE")
- fi
- AC_DEFINE(MMAP_STACK)
- else
- AC_MSG_RESULT("mmap is not good enough")
- fi
- if test ! -z "$MMAP_MIN_ADDRESS"; then
- AC_DEFINE_UNQUOTED(MMAP_MIN_ADDRESS, $MMAP_MIN_ADDRESS)
- fi
- if test ! -z "$MMAP_MAX_ADDRESS"; then
- AC_DEFINE_UNQUOTED(MMAP_MAX_ADDRESS, $MMAP_MAX_ADDRESS)
- fi
- if test "$SIGNAL_HANDLER_PROVIDES_ADDRESS" = "1"; then
- AC_DEFINE(SIGNAL_HANDLER_PROVIDES_ADDRESS)
- fi
- if test ! -z "$TOPOFHEAP"; then
- AC_DEFINE_UNQUOTED(TOPOFHEAP, $TOPOFHEAP)
- fi
- else
- AC_MSG_RESULT("could not compile mmap test");
- fi
- rm -fr conftest*
-
- if test "$configsave" = "yes"; then
-
- dnl ****************************************************************
- dnl The real thing. See whether we can use save/1 and friends. The
- dnl hardest part is to find the start of the data segment.
- dnl ****************************************************************
-
- AC_MSG_CHECKING("_data_start")
- AC_TRY_LINK([extern int _data_start;],
- [ { int *x = &_data_start; }
- ],
- AC_DEFINE(FIRST_DATA_SYMBOL, _data_start)
- AC_MSG_RESULT(yes),
- AC_MSG_RESULT(no))
- AC_MSG_CHECKING("_data")
- AC_TRY_LINK([extern int _data;],
- [ { int *x = &_data; }
- ],
- AC_DEFINE(FIRST_DATA_SYMBOL, _data)
- AC_MSG_RESULT(yes),
- AC_MSG_RESULT(no))
-
- AC_MSG_CHECKING("whether we can get save/1 to work")
- echo '#include "confdefs.h"' > conftest.c
- echo '#define CONFTEST 1' >> conftest.c
- echo '#define TEST 1' >> conftest.c
- cat $srcdir/pl-save.c >> conftest.c
- ac_oldcflags="$CFLAGS"
- CFLAGS="-I$srcdir $CFLAGS"
- (eval $ac_link) 2>&5
- CFLAGS="$ac_oldcflags"
- if test -s conftest && ./conftest -s conftest.save >/dev/null && ./conftest.save > /dev/null; then
- AC_DEFINE(O_SAVE)
- O_SAVE=yes
- AC_MSG_RESULT(yes)
- else
- AC_MSG_RESULT(no)
- fi
- rm -fr conftest*
-
- if test "$O_SAVE" = "yes"; then
- dnl ****************************************************************
- dnl Configuring libraries/linking
- dnl Fixed by Horst von Brand <vonbrand@inf.utfsm.cl>
- dnl ****************************************************************
-
- case "$host" in
- *linux*) STATICLIBS="/usr/lib/libc.a" ;;
- *sunos5*) STATICLIBS="/usr/lib/libc.a -ldl" ;;
- *solaris2*) STATICLIBS="/usr/lib/libc.a -ldl" ;;
- *sunos4*) if test "$ac_cv_func_dlopen" = "yes"; then
- STATICLIBS="/usr/lib/libc.a"
- else
- LDFLAGS="$LDFLAGS -static"
- fi ;;
- *)
- AC_CHECK_PROGS(LDD, ldd, "none")
- if test "$LDD" = "ldd"; then
- ac_old_libs="$LIBS"
- ac_old_ldflags="$LDFLAGS"
- LDFLAGS="$LDFLAGS -static"
- AC_MSG_CHECKING("what kind of static linking is required")
-
- AC_TRY_LINK(
- [],
- [
- #ifdef HAVE_DLOPEN
- dlopen();
- #endif
- ], ldstatic=yes)
-
- if test "$ldstatic" != "yes"; then
- LDFLAGS="$ac_old_ldflags"
- STATICLIBS=/usr/lib/libc.a
- AC_MSG_RESULT("LDFLAGS=$LDFLAGS and STATICLIBS=$STATICLIBS")
- fi
- AC_MSG_RESULT("LDFLAGS=$LDFLAGS")
- fi ;;
- esac
- fi # O_SAVE's fi
- fi # "$configsave" = "yes"
-
- if test "$configloadforeign" = "yes"; then
-
- dnl ****************************************************************
- dnl Foreign language interface
- dnl ****************************************************************
-
- AC_MSG_CHECKING("foreign C-interface")
- AC_TRY_COMPILE([
- #include <stdio.h>
- #include <sys/ldr.h>
- ],
- [ char *buf[10];
- load("test", L_NOAUTODEFER, ".");
- loadquery(L_GETMESSAGES, &buf[2], sizeof(buf) - 8);
- ], AC_DEFINE(O_AIX_FOREIGN)
- AC_MSG_RESULT("AIX load based")
- ac_foreign=yes
- PLFOREIGN=aix_foreign.pl,
- PLFOREIGN=foreign.pl)
-
-
- if test "$ac_foreign" != "yes"; then
- AC_TRY_COMPILE(
- [
- #include <rld.h>
- ],
- [ char *objfiles[10];
- struct mach_header *m_header;
- unsigned long rld_address;
-
- rld_load(stderr, &m_header, objfiles, NULL);
- rld_lookup(NULL, "_init", &rld_address);
- ], AC_DEFINE(O_MACH_FOREIGN)
- AC_MSG_RESULT("MACH rld_load based")
- ac_foreign=yes)
- fi
-
- dnl ****************************************************************
- dnl BSD Unix ld -A .../a.out format foreign interface
- dnl ****************************************************************
-
- if test "$ac_foreign" != "yes"; then
- AC_MSG_RESULT("no OS supported incremental linking")
- AC_MSG_CHECKING("for ld -A")
- cat > conftest.c <<EOF
- int itf(){return 1;}
- int main(int argc, char **argv){ return 0; }
- EOF
- if eval $ac_link && test -s conftest; then
- cat > conftest-sub.c <<EOF
- int init(){return itf();}
- EOF
- if ${CC-cc} -c conftest-sub.c; then
- if ${CC-cc} -o conftest-sub -N -A conftest -T 10000 -lc 2>&5 && test -s conftest-sub 2>&5; then
- AC_DEFINE(HAVE_LD_A)
- AC_DEFINE_UNQUOTED(LD_COMMAND, "$CC")
- AC_MSG_RESULT(yes)
- rm -rf conftest*
- AC_MSG_CHECKING("BSD a.out based loading")
- AC_TRY_COMPILE(
- [
- #include <stdio.h>
- #include <sys/types.h>
- #include <a.out.h>
- ],
- [
- ], AC_DEFINE(O_FOREIGN)
- AC_MSG_RESULT(yes),
- AC_MSG_RESULT(no))
- else
- AC_MSG_RESULT(no)
- fi
- fi
- fi
- fi
- rm -rf conftest*
- fi # configloadforeign
-
- AC_OUTPUT(Makefile README.bin pl.1)
-